<?php

use Phinx\Db\Adapter\MysqlAdapter;
use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableGroup extends Migrator
{
    public function up()
    {
        if (!$this->hasTable('group')) {
            $table = $this->table('group', ['engine' => 'MyISAM'])
                ->setId('id')
                ->setPrimaryKey('id')
                ->setComment('微信群列表');
            $table->addColumn('nickname', 'string', ['limit' => 100, 'null' => false, 'comment' => '微信昵称'])
                ->addColumn('robot_wxid', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '机器人id'])
                ->addColumn('memberCount', 'integer', ['limit' => 10, 'null' => false, 'default' => '0', 'comment' => '微信群人数量'])
                ->addColumn('wxid', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '群通讯ID'])
                ->addColumn('headimgurl', 'string', ['limit' => 200, 'null' => false, 'default' => '', 'comment' => '微信头像'])
                ->addColumn('isManager', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0', 'comment' => '是否是群主 0-无 1-是'])
                ->addColumn('status', 'integer', ['limit' => MysqlAdapter::INT_TINY, 'null' => false, 'default' => '0', 'comment' => '是否激活机器人 0-无 1-是'])
                ->create();
        }
    }

    public function down()
    {
        if ($this->hasTable('group')) {
            $this->dropTable('group');
        }
    }
}
